package org.fao.pims.service.references;

import java.util.List;
import org.fao.pims.model.*;
import org.fao.pims.persistence.*;

public class ReferencesManagerImpl implements ReferencesManager {

	public List getReferencesByPlant(String plantName) throws ReferencesException {
		
		List refList = null;
		
		DocumentDao docDao = new DocumentDaoImpl();
	    refList = docDao.getDocumentsBySubject(plantName);
			
		if( refList != null ) {
			return refList;
		}
		else {
			throw new ReferencesException();
		}

	}

	public List getReferencesByAnimal(String animalName) throws ReferencesException {
		
		List refList = null;
		
		DocumentDao docDao = new DocumentDaoImpl();
	    refList = docDao.getDocumentsBySubject(animalName);
			
		if( refList != null ) {
			return refList;
		}
		else {
			throw new ReferencesException();
		}

	}

	public List getReferencesByAuthor(String authorName) throws ReferencesException {
		
		List refList = null;
		
		DocumentDao docDao = new DocumentDaoImpl();
	    refList = docDao.getDocumentsByAuthor(authorName);
			
		if( refList != null ) {
			return refList;
		}
		else {
			throw new ReferencesException();
		}

	}
}
